import type { IChangePassword, IUserInfo } from '@/interface/user';
import request from '@/utils/request';
import type { IApiResponse } from '../interface/api';

/**
 * 获取用户信息
 * @returns IUserInfo
 */
export const getUserInfo = () => {
  return request<IUserInfo>({
    method: 'get',
    url: '/user/',
  });
};

/**
 * 更新用户信息
 * @param data IUserInfo
 * @returns IApiResponse<any>
 */
export const updateUserInfo = (data: IUserInfo) => {
  return request<IApiResponse<any>>({
    method: 'put',
    url: '/user/update/',
    data,
  });
};

/**
 * 修改密码
 */
export const changeUserPassword = (data: IChangePassword) => {
  return request<IApiResponse<any>>({
    method: 'put',
    url: '/user/password/change/',
    data,
  });
};
